<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>百度地图</title>
    <style type="text/css">
        html {
            height: 100%
        }

        body {
            height: 100%;
            margin: 0px;
            padding: 0px
        }

        #container {
            height: 100%
        }
    </style>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=gVako2Nm7CtU0EO7YivNmjpmW6wnSMWX">
        //v2.0版本的引用方式：src="http://api.map.baidu.com/api?v=2.0&ak=您的密钥"
    </script>
</head>

<body>
    <div id="container"></div>
    <script type="text/javascript">
        var map = new BMap.Map("container");
        // 创建地图实例  
        var point = new BMap.Point(116.404, 39.915);
        // 创建点坐标  
        map.centerAndZoom(point, 5);
        map.enableScrollWheelZoom(true);
        var marker = new BMap.Marker(point); // 创建标注    
        map.addOverlay(marker);
        marker.enableDragging();
        marker.addEventListener("dragend", function (e) {

            var myGeo = new BMap.Geocoder();

            $.ajax({
                type: "get",
                dataType: 'jsonp',
                url: "http://api.map.baidu.com/geocoder/v2/?location=" + e.point.lat + "," + e.point.lng +
                    "&output=json&pois=1&ak=gVako2Nm7CtU0EO7YivNmjpmW6wnSMWX",
                success: function (res) {
                    console.log(res);
                    console.log(res.status);
                    console.log(res.result);
                    alert(res.result.formatted_address);
                }



            });

        })



        // 初始化地图，设置中心点坐标和地图级别
    </script>
</body>

</html>